import { defineStore } from 'pinia'
import {reqUserInfo} from '../reqest'
const useInfoStore = defineStore('info',{
  state:() => ({
    userInfo:{},
    url:''
  }),
  actions:{
    // 发请求，拿数据
    getUserInfo:async function(id){
      let res =await reqUserInfo(id)
      if(res.code === 200){
        this.userInfo = res.data.userInfo.info
        this.url = res.data.userInfo.info.ldy
      }
    }
  },
  getters:{
    baseInfo:(state) => {
      const {id,username,annotation,ldy,qfa,findustry,sindustry,website,type } = state.userInfo
      return {
        id,
        username,
        annotation,
        ldy,
        qfa,
        findustry,
        sindustry,
        website,
        type
      }
    },
    detailInfo:(state) => {
      return state.userInfo.detail 
    }
  }
})

export default useInfoStore